package com.cloudeasy.api.util;

import com.cloudeasy.api.enums.ResultCodeEnum;
import com.cloudeasy.api.exception.CloudEasyException;

import java.util.List;

/**
 * 实体工具类
 */
public class EntityUtil {
    /**
     * 校验数据是否合法
     * 如果不合法，抛出{@link ResultCodeEnum}构造的{@link CloudEasyException}
     *
     * @param fields  {@link List<String>}字段
     * @param strings 要校验的字段数组
     */
    public static void checkParamter(List<String> fields, String[] strings) {
        for (String s : strings) {
            if (!fields.contains(s)) {
                throw new CloudEasyException(ResultCodeEnum.PARAMETER_ERROR);
            }
        }
    }
}
